-- SPDX-License-Identifier: GPL-3.0-or-later

local v_trueround = fk.CreateSkill{
  name = "v_trueround",
}

v_trueround:addEffect(fk.GamePrepared, {
  global = true,
  priority = 11,
  can_refresh = function(self, event, target, player, data)
    local room = player.room
    if not room:getTag("FirstRound") then
      return true
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:setBanner("@v_trueround", 0)
    room:setTag("trueround_notused", true)
  end,
})

v_trueround:addEffect(fk.RoundStart, {
  global = true,
  priority = 11,
  can_refresh = function(self, event, target, player, data)
    local room = player.room
    return room:getTag("trueround_notused")
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    local X = room:getBanner("@v_trueround") or 0
    room:setBanner("@v_trueround", X + 1)
    room:setTag("trueround_notused", false)
  end,
})

v_trueround:addEffect(fk.RoundEnd, {
  global = true,
  priority = 11,
  can_refresh = function(self, event, target, player, data)
    return true
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:setTag("trueround_notused", true)
  end,
})

return v_trueround